//
//  WoDeAcountCell.m
//  SanYiTeaching
//
//  Created by 李文强 on 2019/4/27.
//  Copyright © 2019 SanYi. All rights reserved.
//

#import "WoDeAcountCell.h"

@implementation WoDeAcountCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self initSubView];
        [self initOption];
    }
    return self;
}
- (void)initSubView{
    [self addSubview:self.titleLabel];
    [self addSubview:self.tf];
    [self addSubview:self.editeButton];
}
- (void)initOption{
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@10);
        make.width.equalTo(@100);
        make.height.equalTo(@20);
        make.centerY.equalTo(self.mas_centerY);
    }];
    [_tf mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@0).offset(-10);
        make.width.equalTo(@100);
        make.height.equalTo(@20);
        make.centerY.equalTo(self.mas_centerY);
    }];
    [_editeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@0).offset(-10);
        make.width.equalTo(@40);
        make.height.equalTo(@20);
        make.centerY.equalTo(self.mas_centerY);
    }];
}
- (void)reloadViewLayout{
    _editeButton.hidden  =NO;
    [_editeButton mas_updateConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@0).offset(-10);
        make.width.equalTo(@40);
        make.height.equalTo(@20);
        make.centerY.equalTo(self.mas_centerY);
    }];
    [_tf mas_updateConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.mas_right).offset(-60);
        make.width.equalTo(@100);
        make.height.equalTo(@20);
        make.centerY.equalTo(self.mas_centerY);
    }];
}
- (void)closeViewLayout{
    _editeButton.hidden  =YES;
    [_editeButton mas_updateConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@0).offset(-10);
        make.width.equalTo(@40);
        make.height.equalTo(@20);
        make.centerY.equalTo(self.mas_centerY);
    }];
    [_tf mas_updateConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@0).offset(-10);
        make.width.equalTo(@100);
        make.height.equalTo(@20);
        make.centerY.equalTo(self.mas_centerY);
    }];
}
- (UILabel *)titleLabel{
    if (!_titleLabel) {
        UILabel *label = [[UILabel alloc]init];
        label.text = @"名字";
        label.font = [UIFont systemFontOfSize:14];
        label.textColor = [UIColor darkGrayColor];
        label.textAlignment = 0;
        _titleLabel = label;
    }
    return _titleLabel;
}
- (UITextField *)tf{
    if (!_tf) {
        UITextField *tf = [[UITextField alloc]init];
        tf.font = [UIFont systemFontOfSize:14];
        tf.textColor = TITLECOLOR;
        _tf = tf;
    }
    return _tf;
}
- (UIButton *)editeButton{
    if (!_editeButton) {
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        [button setTitle:@"保存" forState:UIControlStateNormal];
        button.titleLabel.font = [UIFont systemFontOfSize:14];
        [button setTitleColor:SELECTEDCOLOR forState:UIControlStateNormal];
        button.hidden = YES;
        _editeButton = button;
    }
    return _editeButton;
}
//- (void)editeClick:(UIButton *)sender{
//    
//}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (void)drawRect:(CGRect)rect{
    UIBezierPath *path = [[UIBezierPath alloc]init];
    [path moveToPoint:CGPointMake(0, 49)];
    [path addLineToPoint:CGPointMake(self.frame.size.width, 49)];
    [LINCOLOR set];
    [path stroke];
}
@end
